package com.nanning.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nanning.system.domain.WorkCar;
import com.nanning.system.mapper.WorkCarMapper;
import com.nanning.system.service.IWorkCarService;
import org.apache.poi.ss.usermodel.Sheet;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;

/**
 * <p>
 * 部分作业在站在途情况 服务实现类
 * </p>
 *
 * @author zhurenwang
 * @since 2025-05-03
 */
@Service
public class WorkCarServiceImpl extends ServiceImpl<WorkCarMapper, WorkCar> implements IWorkCarService {

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void importData(Sheet sheet6) {
        int rows = sheet6.getPhysicalNumberOfRows();
        for (int i = 0; i < rows; i++) {
            if (i < 2) {
                continue;
            }
            WorkCar workCar = new WorkCar();
            workCar.setArea(sheet6.getRow(i).getCell(1).getStringCellValue());
            workCar.setUnloadCarNum(BigDecimal.valueOf(sheet6.getRow(i).getCell(2).getNumericCellValue()));
            workCar.setInCarNum(BigDecimal.valueOf(sheet6.getRow(i).getCell(5).getNumericCellValue()));
            workCar.setOutCarNum(BigDecimal.valueOf(sheet6.getRow(i).getCell(6).getNumericCellValue()));
            save(workCar);
        }
    }
}
